import React from "react";
import { Router, Route } from "react-router-dom";
import { Bi, Pi, RootContainer } from "@/module-00-codebase/pkg-01-container";
export class Entrance {
  public async enter() {
    const cacheId = Bi.utils.getQueryVariable("target");
    const cache = cacheId ? (await Bi.rpc.send({ resourceName: "innerCache", action: "getone", data: { id: cacheId } }))?.data?.data : undefined;
    let forward, args, token;
    if (!!cache?.content) {
      const content = cache.content;
      [forward, args, token] = [content.forward, content.args, content.token];
      await Bi.sign.out();
      await Bi.sign.in("token", token);
    }
    await Bi.renderer.render(<Router history={Bi.historyFactory.getHistory()}>{<Route path={"/"} component={Pi["/"] as any} />}</Router>, RootContainer.primary);
    if (forward) Bi.navigate.forward(forward, args);
  }
}
